from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument


def generate_launch_description():
    # 声明启动参数
    fcu_url_arg = DeclareLaunchArgument(
        'fcu_url',
        default_value='/dev/ttyUSB0:115200',
        description='FCU串口连接地址'
    )
    
    system_id_arg = DeclareLaunchArgument(
        'system_id',
        default_value='1',
        description='系统ID'
    )
    
    component_id_arg = DeclareLaunchArgument(
        'component_id',
        default_value='1',
        description='组件ID'
    )
    
    # 创建STMROS节点
    stmros_node = Node(
        package='stmros',
        executable='stmros_node',
        name='stmros_node',
        output='screen',
        parameters=[
            {'fcu_url': LaunchConfiguration('fcu_url')},
            {'system_id': LaunchConfiguration('system_id')},
            {'component_id': LaunchConfiguration('component_id')}
        ]
    )
    
    # 创建启动描述
    return LaunchDescription([
        fcu_url_arg,
        system_id_arg,
        component_id_arg,
        stmros_node
    ])